$(function(){
	// 显示今天的贴士
	$.post('cms/tips/today', function(data){
		if (!data || !data.data || !data.data.length) return;
		
		var tips = data.data[0];
		
		var timer;
		var dialog = art.dialog({
			title : '今日小贴士',
			content : '<pre style="width: 310px; white-space: pre-wrap; word-wrap:break-word; overflow:hidden;">' + tips.content + '</pre><div style="text-align:right;color:red;margin:20px 10px 0 0">此窗口<span id="tipsCount"></span>秒后关闭...</div>',

		    fixed : true,
		    width : '30em',
		    padding : '20px 25px 10px 25px',
			esc : false,
			
			// 倒计时
			init: function () {
		    	var that = this, i = tips.displayTime;
		        var fn = function () {
		        	$('#tipsCount').html(i);
		            !i && that.close();
		            i--;
		        };
		        timer = setInterval(fn, 1000);
		        fn();
		    },
		    close: function () {
		    	if (timer) {
		    		clearInterval(timer);
		    	}
				$.post('cms/tips/read', {tipsId : tips.id});
		    }
		});
	});
});